﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Session.aspx.cs" Inherits="TheatreStaff_Session" %>
<%@ Register TagPrefix="custom" Namespace="myControls" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Web.Configuration" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<script type="text/javascript">

    function displayCalendar() {
        var datePicker = document.getElementById('datePicker');
        datePicker.style.display = 'block';
    }
</script>
<script runat ="server" >
    void Page_Load()
    {
        if (!Page.IsPostBack)
            grdSession.SelectedIndex = 0;
        Label15.Text = string.Empty;
        Label16.Text = string.Empty;
    }
    //protected void Cancel(object sender, EventArgs e)
    //{
        
    //    txtSessionTimeI.Text = string.Empty;
    //    ddlCinemaI.SelectedIndex = -1;
    //    //txtDurationI.Text = string.Empty;
    //    Label15.Text = string.Empty;
    //    Label16.Text = string.Empty;
    //    grdSession.DataBind();
    //}
    protected void Clear(object sender, EventArgs e)
    {
        Label15.Text = string.Empty;
        Label16.Text = string.Empty;
    }
    protected void OnItemUpdated_Click(object sender, DetailsViewUpdatedEventArgs e)
    {
        grdSession.DataBind();
        Label15.Text = string.Empty;
        Label16.Text = string.Empty;
    }
    //protected void InsertS_Click(object sender, EventArgs e)
    //{
    //    Label15.Text = string.Empty;
    //    Label16.Text = string.Empty; 
    //    string connectionString;
    //    connectionString = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
    //    SqlConnection con = new SqlConnection(connectionString);
    //    SqlConnection con1 = new SqlConnection(connectionString);
    //    SqlCommand cmd1 = new SqlCommand("INSERT session2(time,cinema) values (@time,@cinema)", con1);
    //    SqlCommand cmd = new SqlCommand("SELECT time,cinema from session2,TheatreStaff,Cinema WHERE TheatreStaff.TheatreId=Cinema.TheatreId AND Cinema.CinemaId=session2.cinema AND Cinema.TheatreId=@TheatreId AND session2.time=@time AND session2.cinema=@cinema", con);
    //    string ParamString = lblId.Text;
    //    Int32 RowCount;
    //    Boolean HasS;

    //    cmd.Parameters.AddWithValue("@TheatreId", ParamString);
    //    cmd.Parameters.AddWithValue("@time", txtSessionTimeI.Text );
    //    cmd.Parameters.AddWithValue("@cinema", ddlCinemaI.SelectedValue);

    //    using (con)
    //    {
    //        con.Open();
    //        SqlDataReader Reader = cmd.ExecuteReader();

    //        if (Reader.HasRows)
    //        {
                
    //            Label15.Text = "The session" + " already exist in the database!";
                //lblCheck.Text = string.Empty;
                //ClientScript.RegisterClientScriptBlock(ClientScript.GetType(), "Focus", "<script language='JavaScript' 'showInsert();'/>");

        //        HasS = true;

        //    }
        //    else
        //    {
        //        HasS = false;

        //    }
        //}
        //using (con1)
        //{
        //    con1.Open();
        //    if (HasS == false)
        //    {
                
        //        cmd1.Parameters.AddWithValue("@time", txtSessionTimeI.Text);
        //        cmd1.Parameters.AddWithValue("@cinema", ddlCinemaI.SelectedValue );
        //        //cmd1.Parameters.AddWithValue("@Duration", txtDurationI.Text);
        //        RowCount = cmd1.ExecuteNonQuery();
        //        txtSessionTimeI.Text = string.Empty;
        //        ddlCinemaI.SelectedIndex =-1;
                //txtDurationI.Text = string.Empty;
                //if (RowCount > 0)
                //{
    //            Label16.Text = "The session " + "has been added sucessfully!";
    //            //lblCorrect.Visible = true;
                

    //            //}
    //        }

    //    }
    //    grdSession.DataBind();
    //}
    protected void function2(object sender, EventArgs e)
    {
        
        TextBox tb2 = (TextBox)dtlSpecial.FindControl("txtSessionTime");
        Label tb3 = (Label)dtlSpecial.FindControl("Label6");
        Label3.Text = tb2.Text;
    

    }
    protected void function4(object sender, EventArgs e)
    {

        DropDownList tb3 = (DropDownList)dtlSpecial.FindControl("ddlCinema");
        Label4.Text = tb3.SelectedItem.Text;


    }
    protected void function3(object source, ServerValidateEventArgs args)
    {

        TextBox tb2 = (TextBox)dtlSpecial.FindControl("txtSessionTime");
        DropDownList tb3 = (DropDownList)dtlSpecial.FindControl("ddlCinema");
        if ( (Label3.Text == tb2.Text) && (Label4.Text == tb3.SelectedItem.Text) )
        {
            Label7.Text = "same";
            args.IsValid = true;

        }
        else
        {

            string connectionString;
            connectionString = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
            SqlConnection con = new SqlConnection(connectionString);
            SqlCommand cmd1 = new SqlCommand("SELECT time,cinema from session2 WHERE time=@time AND cinema =@cinema ", con);
            cmd1.Parameters.AddWithValue("@time", tb2.Text);
            cmd1.Parameters.AddWithValue("@cinema", tb3.Text);
            using (con)
            {
                con.Open();
                SqlDataReader reader = cmd1.ExecuteReader();
                if (reader.HasRows)
                {
                    args.IsValid = false;
                    Label7.Text = "match";
                }
                else
                {
                   Label7.Text  = "NO maetch";
 
                }
            }
        }
    }
</script>
<script type="text/javascript">
    function showInsert() {
        var divInsert = document.getElementById('divInsert');
        divInsert.style.display = 'block';
    }
    function MM_preloadImages() { //v3.0
        var d = document; if (d.images) {
            if (!d.MM_p) d.MM_p = new Array();
            var i, j = d.MM_p.length, a = MM_preloadImages.arguments; for (i = 0; i < a.length; i++)
                if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; } 
        }
    }
    function MM_findObj(n, d) { //v4.01
        var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
            d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
        }
        if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
        for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
        if (!x && d.getElementById) x = d.getElementById(n); return x;
    }
    function MM_swapImage() { //v3.0
        var i, j = 0, x, a = MM_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3)
            if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; }
    }
    function MM_swapImgRestore() { //v3.0
        var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
    }
</script>
 <style type="text/css">
        #datePicker
        {
            display:none;
            position:absolute;
            border:solid 2px black;
            background-color:white;
           
        }
    
    </style>
<style type="text/css">
.center1
{
    padding-left:320px;
}
#divDisplay
{
    border:solid 1px White;
    width:400px;
    padding:15px;
    margin:0px auto;
    text-align:center;
    border:1px solid #333;
}
#divInsert
{
    display:none;
    border:solid 1px black;
    width:500px;
    position:absolute;
    top:200px;
    left:100px;
    padding:10px;
    background-color:Silver;
    color:Black ;
}
.C
{
    color:Green ;
    font-size:larger;
    font-weight :bolder ;
}
.I
{
    color:Maroon ;
    font-size:larger;
    font-weight :bolder ;
}
html
{
  background-image:url('image/back.jpg'); 

    padding:10px;
    color:White;    
  
}
.content1
{
    margin:auto;
    width:850px;
}
.column
{
    float:left;
    width:348px;
}
.selectedRow
{
    background-color:Gray;
}

.content
{
    width:950px;
    margin:auto;
        height: 197px;
}

.link
{
  margin-left:350px; 
     font-weight:bold;
  font-size:large;  
    font-size:x-large;
}
.link2
{
  margin-left:50px; 
     font-weight:bold;
  font-size:large;  
    font-size:x-large;
}
a
{
 color: white;
 text-decoration:underline;
 font-weight:bold;

}
a:hover
{
 color: red; 
  text-decoration:none;
  font-weight:bold;

}
.join
{
   background-color:#0099FF;
  clip:auto;
  font-weight:bold;
  font-size:large;
}
.table2
{
 border-style:solid;
   border-color:Black;
   background-color:White;
   color:Black;  
   width:900px; 
}
.row
{
   background-color:Gray;
   color:White;
}
.ticket
{
   background-color:#CC0000;
color:White;

}

.ticket:hover
{
 color: black; 
  text-decoration:none;


}
    .style1
    {
        width: 509px;
    }
    
.footer
{

     font-weight:bold;
  font-size:large;  

}
.ticket1
{
    padding-left:200px;
}
.view2
{
 padding-left:180px;  
}
.text
{
 font-weight:bold;
}
.button
{
 margin-left:250px;
}
.view3
{
    padding-left:120px;
}
.footer
{

   margin-top:250px;
}
.center
{
    padding-left:410px;
}
.cinema
{
    padding-left:590px;
}
     .menu
{
 padding-left:150px;  

}
     .sessionList:hover
{
 color: White; background-color:rgba(255,0,0,.75);  font-weight:bold;
}
</style>
    <title>Session Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div class="content">
   <asp:Image ID="Image1" Width="1000" Height="130" ImageUrl="~/image/tdk-jun5-bannerbatmanexclusivo2.jpg" runat="server" /><br />
<asp:HyperLink ID="HyperLink14"  CssClass="link" NavigateUrl="~/Default.aspx" runat="server">Home</asp:HyperLink>
<asp:HyperLink ID="HyperLink1"  CssClass="link2" NavigateUrl="~/Session.aspx" runat="server">Session</asp:HyperLink> <asp:HyperLink ID="HyperLink2" CssClass="link2" NavigateUrl="~/Movie.aspx" runat="server">Movies</asp:HyperLink>
<asp:HyperLink ID="HyperLink3" CssClass="link2"  NavigateUrl="~/Price.aspx" runat="server">Prices</asp:HyperLink>
<br />
<br />
   <%--<asp:Label ID="Label05" runat="server"  Text="Theatre" CssClass="cinema" Font-Bold="True" Font-Underline="True"></asp:Label>
        <asp:Label ID="Label5" runat="server"  ForeColor="Yellow"></asp:Label>
      
&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp&nbsp;&nbsp &nbsp&nbsp;&nbsp 
          <asp:Label ID="Label9" runat="server" Text="UserName" Font-Bold="True"></asp:Label>    <asp:LoginName ID="LoginName1" runat="server" /> 
    &nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp&nbsp;&nbsp<asp:LoginStatus ID="LoginStatus1" runat="server" ForeColor="#99CCFF" />
--%>
<table class="center1" >
        <tr>
            <td>
               <asp:Label ID="Label22222" runat="server" CssClass="menu"  Text="Theatre" Font-Bold="True" Font-Underline="True"></asp:Label>  
            </td>
            <td>
                 <asp:Label ID="Label5" runat="server"  ForeColor="Yellow"></asp:Label>
                 &nbsp;&nbsp;
            </td>
       <%-- </tr>
 </table> --%>
    <%--<td>&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp&nbsp;&nbsp &nbsp&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp&nbsp;&nbsp &nbsp&nbsp;&nbsp</td>--%>
<%--&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp&nbsp;&nbsp &nbsp&nbsp;&nbsp --%>
  <%--<table align="center" >
        <tr>--%>
            <td>
                <asp:Label ID="Label12" runat="server" Text="UserName" Font-Bold="True"></asp:Label>
                &nbsp;&nbsp;
            </td>
            <td>
                <asp:LoginName ID="LoginName1" runat="server" /> 
                &nbsp;&nbsp;
            </td>
            <td>
                 <asp:LoginStatus ID="LoginStatus1" runat="server" ForeColor="#99CCFF" />
                 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            </td>
        </tr>
    </table>
        <hr />
  <asp:Label ID="Label8" runat="server" Text="Maintain:" Font-Bold="True" Font-Size="Larger" Font-Underline="True"></asp:Label>
<asp:HyperLink ID="HyperLink4" runat="server" 
            NavigateUrl="~/TheatreStaff/Cinema.aspx" ForeColor="#FFCC99">[Cinemas]</asp:HyperLink>&nbsp;&nbsp;
    <asp:HyperLink ID="HyperLink5" runat="server"  ForeColor="#FFFF99" NavigateUrl="~/TheatreStaff/Movies.aspx">[Movies]</asp:HyperLink> &nbsp;
    <asp:HyperLink ID="HyperLink144" runat="server" NavigateUrl="~/TheatreStaff/Schedule.aspx" ForeColor="#FF9900">[Schedules]</asp:HyperLink>&nbsp;   
 <asp:HyperLink ID="HyperLink117" runat="server" NavigateUrl="~/TheatreStaff/Session.aspx" ForeColor="#FF6699">[Session Times]</asp:HyperLink>&nbsp; 
  <asp:HyperLink ID="HyperLink116" runat="server" NavigateUrl="~/TheatreStaff/SessionDates.aspx" ForeColor="#66FF66">[Session Date]</asp:HyperLink>&nbsp;    
 <asp:HyperLink ID="HyperLink115" runat="server" NavigateUrl="~/TheatreStaff/SpecialTickets.aspx" ForeColor="Aqua">[Specail Price]</asp:HyperLink>&nbsp;
 <asp:HyperLink ID="HyperLink107" runat="server" NavigateUrl="~/TheatreStaff/specialday.aspx" ForeColor="#CCFF33">[Special Ticket Pricing Days]</asp:HyperLink>&nbsp;  
    <asp:HyperLink ID="HyperLink6" runat="server" NavigateUrl="~/TheatreStaff/SalesReports.aspx" ForeColor="#CCFFFF">[Sales Report]</asp:HyperLink>&nbsp; 
            <asp:HyperLink ID="HyperLink11" runat="server" NavigateUrl="~/TheatreStaff/AddNewUser.aspx" ForeColor="#66FF99">[Add New User]</asp:HyperLink>&nbsp;
  <hr />
<h3><asp:Label ID="Label2" Text ="Movie Sesssion Time Maintenance" runat="server" CssClass="center" ForeColor="#FF6699" /></h3>        

                
               <asp:BulletedList ID="BulletedList2"  CssClass="bullet" ForeColor="white" runat="server">
               <%--<asp:ListItem  Text="When you insert the release date, please folow the format: dd/mm/yyyy" />--%>
               <asp:ListItem Text="Click 'Select' to view more details" />
               <asp:ListItem Text="Click 'Edit' to view the update screen to update session time details. You can not edit a session time to another session time which already exist" />
               <asp:ListItem Text="Click 'Cancel' to return to the Movie Session Time Maintenance section" />

               <asp:ListItem Text="Click 'Insert Session Time' to insert a new session time. You can not insert a session time which already exist" />
       
        </asp:BulletedList>
  <asp:ScriptManager ID="ScriptManager1" runat="server" />
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
            
        <div class ="content1">
        <asp:Label ID="lblId" runat="server" Visible="false" ></asp:Label>
         <table  >
            <tr>
                <td> <h3><asp:Label ID="Label1" Text ="Maintain Movie Sesssions Times" Visible="false" runat="server" /></h3></td>
            </tr>
         </table>
            <asp:Label ID="Label3" runat="server"  Visible="false" ></asp:Label>
            <asp:Label ID="Label4" runat="server" Visible="false"></asp:Label>
            <div class="column">
            <asp:Label ID="Label15" CssClass="I" runat="server"  Text="" ></asp:Label> 
                    <%--<asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="CustomValidator"></asp:CustomValidator>--%>
                    <%--<asp:RequiredFieldValidator ID="reqError" runat="server" ControlToValidate="lblError" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>--%>
                    
             <asp:Label ID="Label16" CssClass="C" runat="server" Text=""></asp:Label>
           
            <asp:GridView ID="grdSession"
            AllowPaging="true" DataSourceID ="srcgrdSession"  SelectedRowStyle-CssClass="selectedRow" 
            AutoGenerateSelectButton ="true"
            DataKeyNames ="sessionid" AutoGenerateColumns ="false" runat="server" 
                 Height="360px" Width="16px" OnSelectedIndexChanged ="Clear"  RowStyle-CssClass="sessionList">
                <Columns >
                    <custom:DeleteButtonField CommandName="Delete" ConfirmText ="Are you sure that you want to delete this record?" />
                    <%--<asp:BoundField DataField="sessionid" HeaderText ="Session Id" />--%>
                    <%--<asp:BoundField DataField ="sessionid" HeaderText ="Session Id" />--%>
                    <asp:BoundField DataField ="cinema" HeaderText ="Cinema Id" />
                    <asp:BoundField DataField ="time"  HeaderText ="Session Time" DataFormatString ="{0:t}" />
                </Columns>
            </asp:GridView> <asp:HyperLink ID="HyperLink17" NavigateUrl ="~/TheatreStaff/InsertSessionTime.aspx" runat="server">Insert Session Time</asp:HyperLink>
           </div>
             
         <div class="column">
              <asp:Label ID="Label7" runat="server" Visible="false" ></asp:Label>
               <asp:DetailsView ID="dtlSpecial" 
               AutoGenerateEditButton ="true"  OnItemUpdated ="OnItemUpdated_Click"   
               AutoGenerateRows ="false" runat="server" DataKeyNames ="sessionid" DataSourceID ="srcSessionSelect">
                <Fields >
                  
                    <asp:TemplateField HeaderText ="Session Time" HeaderStyle-Font-Bold="true">
                        <ItemTemplate>
                            <%# Eval("time","{0:t}")%> 
                        </ItemTemplate>
                         <EditItemTemplate>
                                  <asp:TextBox
                                    id="txtSessionTime"
                                    Text='<%# Bind("time") %>'
                                    Runat="server" OnDataBinding="function2"/>
                             <asp:CustomValidator  OnServerValidate="function3" ControlToValidate="txtSessionTime" ID="CustomValidator1" runat="server" ErrorMessage="This session time already exist , please try another!"></asp:CustomValidator>                
                                  <asp:RequiredFieldValidator
                                    id="reqTime"
                                    ControlToValidate="txtSessionTime"
                                    Text="(Required)"
                                    Runat="server" />
                                <asp:RegularExpressionValidator ID="regTime"
                                    runat="server" ErrorMessage="(Please enter the time in the 
                                    following format - HH:MM)"
                                    ControlToValidate ="txtSessionTime" ValidationExpression="([0-1]\d|2[0-3]):([0-5]\d)"></asp:RegularExpressionValidator>
                            </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText ="Cinema" HeaderStyle-Font-Bold="true">
                        <ItemTemplate>
                            <asp:Label ID="Label6" runat="server" Text='<%# Eval("cinema")%>'></asp:Label>   
                        </ItemTemplate>
                         <EditItemTemplate >
                         <asp:DropDownList 
                                    ID="ddlCinema" 
                                     DataSourceID ="srcCinema" 
                                     DataTextField ="CinemaId"
                                     DataValueField ="CinemaId"  
                                     SelectedValue='<%# Bind("cinema") %>'
                                     runat="server" AppendDataBoundItems ="true" OnDataBound="function4" >
                                     <asp:ListItem Text ="Select" Value ="-1" />
                                    </asp:DropDownList> 
                         
                                <asp:RequiredFieldValidator
                                    id="reqMovie"
                                    ControlToValidate="ddlCinema"
                                    InitialValue ="-1" 
                                    Text="(Required)"
                                    Runat="server" />
                        </EditItemTemplate>
                    </asp:TemplateField>
                   <%-- <asp:TemplateField HeaderText ="Duration" HeaderStyle-Font-Bold="true" >
                        <ItemTemplate >
                             <%# Eval("Duration")%>
                        </ItemTemplate>
                        <EditItemTemplate >
                             <asp:TextBox
                            id="txtDuration"
                            Text='<%# Bind("Duration") %>'
                            Runat="server"/>
                          <asp:RequiredFieldValidator
                            id="reqDuration"
                            ControlToValidate="txtDuration"
                            Text="(Required)"
                            Runat="server" />
                            <asp:CompareValidator ID="CompareValidator1" ControlToValidate="txtDuration" 
                            runat="server" ErrorMessage="(Please enter a numeric value for duration)" Type="Integer" Operator="DataTypeCheck"></asp:CompareValidator> 
                        </EditItemTemplate>
                    </asp:TemplateField>--%>
                  </Fields>
               </asp:DetailsView>
           </div>      
    </div>
    </ContentTemplate></asp:UpdatePanel>
     <%--<div id="divInsert">
        <fieldset >
            <legend >Insert Session Times</legend>
            <table>
               
                <tr>
                    <td>
                        <asp:Label ID="Label3" runat="server" Text="Session Time"></asp:Label>
                    </td>
                    <td>
                        <asp:TextBox ID="txtSessionTimeI" runat="server"></asp:TextBox>
                    </td>
                    <td>    
                        <asp:RequiredFieldValidator ID="reqSessionTimeI" runat="server" ControlToValidate="txtSessionTimeI" ErrorMessage="(Required)"></asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="Label4" runat="server" Text="Cinema"></asp:Label>
                    </td>
                    <td>
                        <asp:DropDownList 
                        ID="ddlCinemaI" 
                         DataSourceID ="srcCinema" 
                         DataTextField ="CinemaId"
                         DataValueField ="CinemaId"
                         runat="server" AppendDataBoundItems ="true" >
                         <asp:ListItem Text ="Select" Value ="-1" />
                        </asp:DropDownList>   
                    </td>
                    <td>
                       <asp:RequiredFieldValidator
                        id="reqMovieI"
                        ControlToValidate="ddlCinemaI"
                        InitialValue ="-1" 
                        Text="(Required)"
                        Runat="server" /> 
                    </td>
                </tr>--%>
               <%-- <tr>
                    <td>
                        <asp:Label ID="lblD" runat="server" Text="Duration"></asp:Label>
                    </td>
                    <td>
                         <asp:TextBox
                            id="txtDurationI"
                            Runat="server"/>
                    </td>
                    <td>
                          <asp:RequiredFieldValidator
                            id="reqDuration"
                            ControlToValidate="txtDurationI"
                            Text="(Required)"
                            Runat="server" />
                            <asp:CompareValidator ID="CompareValidator1" ControlToValidate="txtDurationI" 
                            runat="server" ErrorMessage="(Please enter a numeric value for duration)" Type="Integer" Operator="DataTypeCheck"></asp:CompareValidator> 
                    </td>
                </tr>--%>
         <%--   </table>
            <table>
                <tr>
                <td>
                    <%--<asp:Button ID="Button1"   runat="server" Text="Button" />--%>
                    <%--<asp:LinkButton ID="btnInsert" OnClick ="InsertS_Click" runat="server">Insert</asp:LinkButton>
                </td>
                <td>
                    <asp:LinkButton ID="btnCancel" OnClick ="Cancel" CommandName="Cancel" CausesValidation ="false"  runat="server">Cancel</asp:LinkButton>
                </td>
                </tr>
            </table>
        </fieldset> 
      </div> --%>
       <asp:SqlDataSource ID="srcgrdSession" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            SelectCommand="SELECT session2.sessionid,
            session2.time,session2.cinema FROM session2,Cinema,TheatreStaff WHERE 
            session2.cinema=Cinema.CinemaId AND
            TheatreStaff.TheatreId=Cinema.TheatreId AND TheatreStaff.TheatreStaffUserName = @username Order By session2.cinema,session2.time"
            DeleteCommand ="DELETE session2 WHERE sessionid=@sessionid "  >
            
                 <SelectParameters>
                  <asp:Parameter Name ="username" Type ="string"/> 
                 </SelectParameters>
            
            </asp:SqlDataSource>
         
            <asp:SqlDataSource ID="srcSessionSelect" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
            SelectCommand="SELECT session2.sessionid,
            session2.time,session2.cinema FROM session2 WHERE sessionid=@sessionid"
            UpdateCommand ="UPDATE session2 SET time=@time,
            cinema=@cinema
            WHERE sessionid=@sessionid"
            runat="server">
                <SelectParameters>
                  <asp:ControlParameter Name ="sessionid" ControlID ="grdSession" />
                </SelectParameters>
                <UpdateParameters >
                    <asp:Parameter Name="sessionid" DbType ="Int32" />
                    <%--<asp:Parameter Name="time" DbType ="Time"    />--%>
                </UpdateParameters>
            </asp:SqlDataSource>
      <%-- <asp:SqlDataSource ID="srcSessionSelect"
                runat="server" 
                ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                SelectCommand="SELECT  Schedule.ScheduleStartDate,datesession.ses皜ionid,session2.time, session2.cinema, 
                datesession.date, datesession.ticketsold,datesession.scheduleid, 
                datesession.sessiontype, Movie.MovieTitle,datesession.movieid FROM session2 
                INNER JOIN datesession ON 
                session2.sessionid = datesession.sessionid INNER JOIN Movie ON 
                datesession.movieid = Movie.MovieId INNER JOIN Cinema ON 
                session2.cinema = Cinema.cinema INNER JOIN TheatreStaff ON 
                Cinema.TheatreId = TheatreStaff.TheatreId INNER JOIN Schedule ON TheatreStaff.TheatreId=Schedule.TheatreId WHERE
                (datesession.sessionid=@sessionid)"
                UpdateCommand ="UPDATE datesession SET date=@date,
                movieid=@movieid,sessiontype=@sessiontype, scheduleid=@scheduleid
                WHERE sessionid=@sessionid AND date=@date"
                InsertCommand="INSERT INTO datesession(date,movieid,sessiontype,scheduleid)
                VALUES (@date,@movieid,@sessiontype,@scheduleid)"
               >
                
                 <SelectParameters>
                  <%--<asp:Parameter Name ="username" Type ="string"/> 
                <%--  <asp:ControlParameter Name ="sessionid" ControlID ="grdSession" />
                </SelectParameters>
                <UpdateParameters >--%>
                    <%--<asp:ControlParameter Name="sessiontype"  ControlID ="ddlType" 
                    PropertyName ="SelectedValue"/>--%>
                   <%-- <asp:Parameter Name="sessionid" DbType ="Int32" />
                    <asp:Parameter Name="date" DbType ="Date"  />
                </UpdateParameters>
        
            </asp:SqlDataSource>
            <asp:SqlDataSource ID="srcType" runat="server" 
                  ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                  SelectCommand="SELECT DISTINCT sessiontype FROM datesession">
            </asp:SqlDataSource>--%>
            <asp:SqlDataSource ID="srcCinema" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            SelectCommand="SELECT DISTINCT CinemaId FROM Cinema WHERE TheatreId=@TheatreId">
                <SelectParameters >
                    <asp:ControlParameter Name ="TheatreId" ControlID ="lblId"/>
                </SelectParameters>
            </asp:SqlDataSource>
           <%-- <asp:SqlDataSource ID="srcSchedule" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            SelectCommand="SELECT ScheduleId, ScheduleStartDate FROM Schedule WHERE TheatreId=@TheatreId">
                <SelectParameters >
                    <asp:ControlParameter Name ="TheatreId" ControlID ="lblId"/>
                </SelectParameters>
            </asp:SqlDataSource>--%>
        
        
   <table align="left"  cellpadding="15" ><tr><td>Copyright@2012 MovieTix</td><td><asp:HyperLink ID="HyperLink8"  CssClass="footer" NavigateUrl="~/Default.aspx" runat="server">Homepage</asp:HyperLink></td><td><asp:HyperLink ID="HyperLink9"  CssClass="footer" NavigateUrl="~/TheatreStaff/Session.aspx" runat="server">Session</asp:HyperLink></td><td><asp:HyperLink ID="HyperLink10"  CssClass="footer" NavigateUrl="~/TheatreStaff/Movies.aspx" runat="server">Movies</asp:HyperLink></td><td><asp:HyperLink ID="HyperLink12"  CssClass="footer" NavigateUrl="~/register.aspx" runat="server">Register</asp:HyperLink></td><td><asp:HyperLink ID="HyperLink13"  CssClass="footer" NavigateUrl="~/Login.aspx" runat="server">Log In</asp:HyperLink></td></tr></table>
      </div>
    </form>
</body>
</html>